﻿@namespace BlazorStrap.V4
@inherits BlazorStrap.Shared.Components.Modal.BSModalBase

@if (ShouldRenderContent)
{
    if (Content == null)
    {
        <div class="@ClassBuilder" tabindex="-1" @attributes="Attributes" style="@Style" @ref="MyRef" data-blazorstrap="@DataId" data-bs-backdrop="@Backdrop" data-bs-keyboard="@((!DisableEscapeKey && !IsManual) ? "true" : "false")" data-bs-allowscroll="@(AllowScroll ? "true" : "false")" data-bs-manual="@(IsManual ? "true" : "false")">

            <div class="@DialogClassBuilder">
                <div class="@ContentClassBuilder">
                    <CascadingValue Value="this">
                        @ChildContent
                    </CascadingValue>
                </div>
            </div>

        </div>
    }
    else
    {
        <div class="@ClassBuilder" tabindex="-1" @attributes="Attributes" style="@Style" @ref="MyRef" data-blazorstrap="@DataId" data-bs-backdrop="@Backdrop" data-bs-keyboard="@((!DisableEscapeKey && !IsManual) ? "true" : "false")" data-bs-allowscroll="@(AllowScroll ? "true" : "false")" data-bs-manual="@(IsManual ? "true" : "false")">
            @if (ShouldRenderContent)
            {
                <div class="@DialogClassBuilder">
                    <div class="@ContentClassBuilder">
                        @if (Header != null)
                        {
                            <div class="@HeaderClassBuilder">
                                @Header
                                @if (HasCloseButton)
                                {
                                    <BSCloseButton Class="ml-auto" @onclick="EventUtil.AsNonRenderingEventHandler(ClickEvent)" data-bs-dismiss="modal" aria-label="Close" />
                                }
                            </div>
                        }
                        <div class="@BodyClassBuilder">
                            <CascadingValue Value="this">
                                @Content(this)
                            </CascadingValue>
                        </div>
                        @if (Footer != null)
                        {
                            <div class="@FooterClassBuilder">
                                @Footer!(this)
                            </div>
                        }
                    </div>
                </div>
            }
        </div>
    }
}